﻿using NAnt.Core.Attributes;

namespace NAnt.SVN.Tasks
{
    /// <summary>
    /// Implementation of the copy command
    /// You can run this tasc with the svncopy tag in NAnt.
    /// $Id$
    /// </summary>
    [TaskName("svncopy")]
    public class Copy : SVNTask
    {
        #region Private Fields

        string source = string.Empty;
        string destination = string.Empty;
        string message = string.Empty;

        #endregion

        #region Public Fields

        /// <summary>
        /// The source url
        /// </summary>
        [TaskAttribute("source", Required = true)]
        [StringValidator()]
        public virtual string Source
        {
            get{ return source; }
            set{ source = value; }
        }

        /// <summary>
        /// The destination url
        /// </summary>
        [TaskAttribute("destination", Required = true)]
        [StringValidator()]
        public virtual string Destination
        {
            get { return destination; }
            set { destination = value; }
        }

        /// <summary>
        /// The message
        /// </summary>
        [TaskAttribute("message", Required = true)]
        [StringValidator()]
        public string Message
        {
            get { return message; }
            set { message = value; }
        }

        #endregion

        /// <summary>
        /// Initialize command
        /// </summary>
        protected override void InitializeSVNTask()
        {
            Command = SVNCommands.COPY;
            Options.Add(quote(Source));
            Options.Add(quote(Destination));
            Options.Add(SVNFlags.MESSAGE);
            Options.Add(quote(Message));
        }
    }
}
